var browserVersion = window.navigator.userAgent.toUpperCase();
var isOpera = browserVersion.indexOf("OPERA") > -1 ? true : false;
var isFireFox = browserVersion.indexOf("FIREFOX") > -1 ? true : false;
var isChrome = browserVersion.indexOf("CHROME") > -1 ? true : false;
var isSafari = browserVersion.indexOf("SAFARI") > -1 ? true : false;
var isIE = (!!window.ActiveXObject || "ActiveXObject" in window);
var isIE9More = (! -[1, ] == false);
//console.log('======================');
//console.log(isOpera);
//console.log(isFireFox);
//console.log(isChrome);
//console.log(isSafari);
//console.log(isIE);
//console.log(isIE9More);
//console.log('======================');
function reinitIframe(iframeId, minHeight) {
    try {
    	
        var iframe = document.getElementById(iframeId);
        
        
        var bHeight = 0;
        if (isChrome == false && isSafari == false)
            bHeight = iframe.contentWindow.document.body.scrollHeight;
        var dHeight = 0;
        if (isFireFox == true){
            dHeight = iframe.contentWindow.document.documentElement.offsetHeight + 2;
//          console.log(iframe.contentWindow.document.documentElement)
//          console.log(iframe.contentWindow.document.body)
        }
        else if (isIE == false && isOpera == false){
            //dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
            dHeight = iframe.contentWindow.document.body.scrollHeight;
            // console.dir(iframe.contentWindow.document.body)
            // console.log(dHeight)
        }
        else if (isIE == true && isIE9More) {//ie9+
            var heightDeviation = bHeight - eval("window.IE9MoreRealHeight" + iframeId);
            if (heightDeviation == 0) {
                bHeight += 3;
            } else if (heightDeviation != 3) {
                eval("window.IE9MoreRealHeight" + iframeId + "=" + bHeight);
                bHeight += 3;
            }
        }
        else{//ie[6-8]、OPERA
            bHeight += 3;
		}
        var height = Math.max(bHeight, dHeight);
        if (height < minHeight) height = minHeight;
        iframe.style.minHeight = height + "px";
    } catch (ex) { }
}
function startInit(iframeId, minHeight) {
    eval("window.IE9MoreRealHeight" + iframeId + "=0");
    var k =1;
    console.log('-----------------------------------------------');
    var timer = window.setInterval("reinitIframe('" + iframeId + "'," + minHeight + ")", 100);
    
//  if(k==1){
//	    setTimeout(function(){
//	    	window.clearInterval(timer);
//	    	console.log('-----------------------------------------------');
//	    	k=2;
//	    },2000)
//  }
//  if(k==2){
//  	var timer = window.setInterval("reinitIframe('" + iframeId + "'," + minHeight + ")", 100);
//  }
    
}